import {instance, myaxios} from '@/api/axios.js'
import axios from 'axios'

// 首页热映
// 最受好评的电影
const getTopRatedMovies = () => {
    return instance.get("index/topRatedMovies")
}
// 热映列表
const getMovieOnInfoList = () => {
    return instance.get("index/movieOnInfoList")
}
// 更多热映
const getMoreComingList = (movieIds) => {
    return instance.get("index/moreComingList?movieIds=" + movieIds)
}

// 影院
// 附近影院筛选条件
const getFilterCinema = (cityId) => {
    return instance.get(`index/filterCinemas?ci=${cityId}`)
}
// 附近影院
const getCiname = (day = '2021-11-12', districtId = -1, hallType = -1, brandId = -1, serviceId = -1, cityId = 1, lat = 23.135636443326355, lng = 113.42422402238324) => {
    return myaxios.get(`index/moreCinemas?day=${day}&offset=0&limit=20&districtId=${districtId}&lineId=-1&hallType=${hallType}&brandId=${brandId}&serviceId=${serviceId}&areaId=-1&stationId=-1&item&updateShowDay=true&reqId=1636710166221&cityId=${cityId}&lat=${lat}&lng=${lng}`)
}

// 主页待映
// 近期最受期待列表
// id 是city id，没有获取经纬度，先写默认 ci=1
const getMostExpected = (cityId) => {
    return instance.get(`index/mostExpected?ci=${cityId}&limit=10&offset=0`)
}
// 待映列表
const getcomingList = (cityId) => {
    return instance.get(`index/comingList?ci=${cityId}&limit=10`)
}
// 更多待映
const getExpectedComingList = (cityId, movieIds) => {
    return instance.get(`index/moreComingList?ci=${cityId}&limit=10&movieIds=${movieIds}`)
}

// 经典电影
const getMoreClassicList = () => {
    return instance.get(`index/moreClassicList?sortId=1&showType=3&limit=10&offset=0`)
}

// 获取城市
const getCity = (lat, lng) => {
    return instance.get(`city/latlng?lat=${lat}&lng=${lng}`)
}
// 城市列表
const getCityList = (lat, lng) => {
    return instance.get(`cities.json`)
}

// 搜索建议
const getSearchSuggest = (val) => {
    return myaxios.get(`search/suggest?kw=${val}&cityId=1`)
}

// 视频
const getVideo = (val = 0) => {
    return instance.get(`video/${val}`)
}

// 影片介绍（购票页面简介）
const getIntro = (id = 916) => {
    return instance.get(`movie/intro?movieId=${id}`)
}
// 上映日期
const getShowDays = (movieId = 916, cityId = 20) => {
    return instance.get(`movie/showdays?movieId=${movieId}&cityId=${cityId}`)
}
// 影片上映影院筛选条件
const getSelectItem = (movieId = 916, cityId = 1, showDate = '2021-11-13') => {
    return instance.get(`movie/select/items?movieid=${movieId}&cityId=${cityId}&showDate=${showDate}`)
}
// 影院筛选
const getSelectCinemas = (day='2024-12-12',movieId=916,cityId=20,lat='23.135610180010865',lng='113.42416693422547',districtId=-1,brandIds='%5B-1%5D',serviceIds=-1) =>{
    return instance.get(`movie/select/cinemas?limit=20&offset=0&client=iphone&channelId=4&showDate=${day}&movieId=${movieId}&sort=distance&cityId=${cityId}&lat=${lat}&lng=${lng}&districtId=${districtId}&lineId=-1&areaId=-1&stationId=-1&brandIds=%5B${brandIds}%5D&serviceIds=%5B${serviceIds}%5D&hallTypeIds=%5B"all"%5D&languageIds=%5B"all"%5D&dimIds=%5B"all"%5D`)
}

const getWant = () => {
    // return axios.get(`https://piaofang.maoyan.com/i/api/movie/getWantData?movieId=1467290`)
    return axios.get('/WatchData.json')
}


export { getMovieOnInfoList, getTopRatedMovies, getMostExpected, getcomingList, getMoreClassicList, getMoreComingList, getExpectedComingList, getSearchSuggest, getCity, getCityList, getFilterCinema, getCiname, getVideo, getIntro, getShowDays,getSelectItem,getSelectCinemas,getWant }

